package com.qf.fmall.utils;

import java.util.Random;

public class SaltUtils {

    public static final String[] CHAR_ARR = {"a","b","c","d","e","f","g","h","i"};

    /**
     * 生成指定长度的随机字符串
     * @param length
     * @return
     */
    public static String createSalt(int length){

        StringBuffer stringBuffer = new StringBuffer();
        Random random = new Random();
        for (int i = 0; i < length; i++) {
            int index = random.nextInt(CHAR_ARR.length);
            String s = CHAR_ARR[index];
            stringBuffer.append(s);
        }
        return stringBuffer.toString();
    }

}
